#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>



int main()
{
    // 加盐
    char salt[17] = "qwertyuiopasdfgh";
    char passwd[100] = { 0 };
    printf("请输入你的密码:\n");
    scanf("%s", passwd);

    strcat(passwd, salt);// 拼接盐值
    printf("加盐后的原密码:%s\n", passwd);

    unsigned char hashPasswd[SHA256_DIGEST_LENGTH] = { 0 };
    SHA256(passwd, strlen(passwd), hashPasswd);// 计算哈希值

    for(int i = 0; i < SHA256_DIGEST_LENGTH; i++)
        printf("%x", hashPasswd[i]);
    printf("\n");
    return 0;
}